<div id="supervise-modal" style="top: 10%;" class="modal fade modal_small" role="dialog" aria-labelledby="myModalLabel1" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title"></h4>
            </div>
            <form action="<?php echo getUrl('merchant/saveSupervise')?>" class="form-horizontal" method="post" id="supervise-form" novalidate="novalidate">
                <div class="form-body">
                    <div class="form-group">
                        <label class="control-label col-md-2">监管局<span class="required">*</span></label>
                        <div class="col-md-10">
                            <input class="form-control required"  name="supervise" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">监管部门<span class="required">*</span></label>
                        <div class="col-md-10">
                            <input class="form-control required"  name="supervise_department" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">监管人<span class="required">*</span></label>
                        <div class="col-md-10">
                            <input class="form-control required"  name="supervise_name" type="text">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-2">监管电话<span class="required">*</span></label>
                        <div class="col-md-10">
                            <input class="form-control required"  name="supervise_tel" type="text">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">监管头像（男）<span class="required">*</span></label>
                        <div class="col-md-10">
                            <div class="supervise-file fileinput fileinput-new" data-provides="fileinput"><input type="hidden">
                                <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px; line-height: 140px;">
                                    <img src="<?php echo getDefaultImg()?>" class="supervise_man_portrait"/>
                                </div>
                                <div>
                                    <span class="btn default btn-file">
                                        <span class="fileinput-new">选择图片</span>
                                            <span class="fileinput-exists">改变</span>
                                        <input name="supervise_man_portrait" type="file">
                                    </span>
                                    <a href="#" class="btn default fileinput-exists" data-dismiss="fileinput">删除</a>
                                </div>
                            </div>
                            <div class="clearfix margin-top-10">
                                <span>
                                    <i class="fa fa-exclamation-triangle"></i>
                                </span>
                                图片格式：gif,png,jpg;大小:2MB
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-2">监管头像（女）<span class="required">*</span></label>
                        <div class="col-md-10">
                            <div class="supervise-file fileinput fileinput-new" data-provides="fileinput"><input type="hidden">
                                <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px; line-height: 140px;">
                                    <img src="<?php echo getDefaultImg()?>" class="supervise_woman_portrait"/>
                                </div>
                                <div>
                                    <span class="btn default btn-file">
                                        <span class="fileinput-new">选择图片</span>
                                            <span class="fileinput-exists">改变</span>
                                        <input name="supervise_woman_portrait" type="file">
                                    </span>
                                    <a href="#" class="btn default fileinput-exists" data-dismiss="fileinput">删除</a>
                                </div>
                            </div>
                            <div class="clearfix margin-top-10">
                                <span>
                                    <i class="fa fa-exclamation-triangle"></i>
                                </span>
                                图片格式：gif,png,jpg;大小:2MB
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <input type="hidden" name="id" value="">
                        <input type="hidden" name="merchant_id">
                        <button class="btn green">保存</button>
                        <button class="btn default" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> 关闭</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        var merchantId = '<?php echo $info['id']?>';
        var model = $('#supervise-modal');

        $(".supervise-add").live('click',function () {
            var defaultImg = '<?php echo getDefaultImg()?>';
            model.find('.modal-title').html('添加监管信息' );
            model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
            model.find('.show_message_error').remove();
            model.find('input').val('');
            model.find('img').attr('src', defaultImg);
            model.find('[name="merchant_id"]').val(merchantId);
            model.modal();
        });

        $('.edit-supervise').live('click', function(){
            var id = $(this).attr('data-id');
            model.find('[name="id"]').val(id);
            model.find('[name="merchant_id"]').val(merchantId);
            l_blockUI();
            $.ajax('<?php echo getUrl('merchant/getSuperviseList')?>?id='+merchantId, {
                dataType:'json',
                type:'get',
                error:function(){
                    show_message({status:0, info:'请求超时'});
                    App.unblockUI();
                },
                timeout:60000,
                success:function(data,textStatus,jqXHR){
                    if(!data){
                        show_message({status:0, info:'请求超时'});
                        return;
                    }
                    var e = data[id];
                    model.find('.modal-title').html('编辑监管信息 - '+ e.supervise );
                    model.find('.has-error').removeClass('has-error').find('.validate_message').remove();
                    model.find('.show_message_error').remove();
                    for(var k in e){
                        if (k == 'supervise_woman_portrait' || k == 'supervise_man_portrait'){
                            model.find('.'+k).attr('src', e[k]);
                        }else{
                            model.find('[name="'+k+'"]').val(e[k]);
                        }
                    }
                    model.modal();
                    App.unblockUI();
                }
            });
            return false;
        });

        $.e_validate.init('#supervise-form',{modal:model,ignore:'',successCallback:function(){
            getDistrictList();
        }});
    });
</script>